<%@page import="com.nescafe.nescafepromo.entity.ExtraPoint"%>
<%@page import="java.util.Date"%>
<%@page import="com.google.appengine.api.datastore.Entity"%>
<%@page import="java.util.List"%>
<%@page import="com.nescafe.nescafepromo.model.NPResponse"%>
<%@page import="com.nescafe.nescafepromo.controller.AdminController"%>
<%@page import="com.nescafe.nescafepromo.command.CommandType"%>
<%@page import="com.nescafe.nescafepromo.model.NPRequest"%>
<%@page import="com.nescafe.nescafepromo.util.FormatUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String now = FormatUtil.formatDate(new Date());
	NPRequest npReq = new NPRequest(request, CommandType.SEARCH_EXTRA_POINTS);
	if (!request.getParameterMap().containsKey("email")) {
		npReq.addParam("email", null);
	}
	if (!request.getParameterMap().containsKey("to")) {
		npReq.addParam("to", now);
	}
	if (!request.getParameterMap().containsKey("from")) {
		npReq.addParam("from", now);
	}

	AdminController ctr = new AdminController();
	NPResponse npRes = ctr.process(npReq);
	List<Entity> result = npRes.getResults();
%>

<div class="table-container">
	<table border="1" cellpadding="5px">
		<tr>
			<th>Email</th>
			<th>Date</th>
		</tr>
		<%
			for (Entity entity : result) {
				ExtraPoint ep = new ExtraPoint(entity);
		%>
		<tr>
			<td><%=ep.getParent().getName()%></td>
			<td><%=ep.getDisplayDate()%></td>
		</tr>
		<%
			}
		%>

		<!-- 
		<tr>
			<td>103030030303</td>
			<td>Fretzhie Abatayo</td>
			<td>March 25, 2012</td>
		</tr>
		<tr>
			<td>1030300303044</td>
			<td>Juan Dela Cruz</td>
			<td>March 26, 2012</td>
		</tr>
		<tr>
			<td>10301525</td>
			<td>Will Smith</td>
			<td>March 26, 2012</td>
		</tr>
		<tr>
			<td>10301525</td>
			<td>Will Smith</td>
			<td>April 1, 2012</td>
		</tr>
		<tr>
			<td>23698262656</td>
			<td>Danny Dough</td>
			<td>April 1, 2012</td>
		</tr> -->
	</table>

</div>
